{% extends "base.html" %}
{% load i18n %}

{% block pageContent %}
	{% if playlistUser %}
		{% if playlists %}
			<ul>
			{% for playlist in playlists %}
				<li>
					<a href="/playlist/{{ playlist.getKey }}">{{ playlist.title }}</a>
					( {% blocktrans count playlist.numVideos as numVideos %}
						{{ numVideos }} video
					  {% plural %}
					    {{ numVideos }} videos
					  {% endblocktrans %}
					)
					{% if myplaylist %}
					[ <a href="/playlist/{{ playlist.getKey }}?edit=1">{% trans "Edit" %}</a>
					| <a href="javascript:;" onclick="javascript:deletePlaylist('{{ playlist.getKey }}', '{{ playlist.title }}');">{% trans "Delete" %}</a> ]
					{% endif %}
				</li>
			{% endfor %}
			</ul>
		{% else %}
			<p>{% trans "You haven't created any playlists yet." %}</p>
		{% endif %}
		{% if myplaylist %}
			<h3><a href="/playlist/create">{% trans "Create Playlist" %}</a></h3>
		{% endif %}
	{% else %}
		<p class="red">{% trans "User not found!" %}</p>
	{% endif %}
	
{% if myplaylist %}
<script type="text/javascript">
<!--
function deletePlaylist(playlistKey, playlistTitle)
{
	if (!playlistKey) {
		return false;
	}
	if (confirm('{% trans "Are you sure you want to delete this playlist" %}: '+playlistTitle+'?')) {
		$.post('http://{{ siteHostname }}/playlist/edit/'+playlistKey+'?delete=1', {delete: 1}, function(data) {
			if (data.success) {
				alert('{% trans "Delete successful!" %}');
				document.location.href = document.location.href;
			} else {
				alert('{% trans "Delete failed! You might have logged out, or the playlist has been deleted already." %}');
			}
		}, 'json');
	}
}
-->
</script>
{% endif %}
{% endblock pageContent %}
